package com.link.base.base.report.service;

import com.link.base.base.report.dao.mybatis.mapper.ActiveConversionRateMapper;
import com.link.base.base.report.model.ActiveConversionRate;
import com.link.core.basic.dao.mapper.BasicMapper;
import com.link.core.basic.service.BasicServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * 活动转化率-
 *
 * @author 黄正杨
 * @date 2019/03/08 13:48
 */
@Service
public class ActiveConversionRateServiceImpl extends BasicServiceImpl<ActiveConversionRate> implements ActiveConversionRateService {

    @Resource
    private ActiveConversionRateMapper activeConversionRateMapper;

    @Override
    public BasicMapper<ActiveConversionRate> getBasicMapper() {
        return activeConversionRateMapper;
    }

    @Override
    @Transactional
    public void synchronizationData() throws Exception {
        activeConversionRateMapper.synchronizationData();
        activeConversionRateMapper.updateHeadData();
        List<String> dataList = activeConversionRateMapper.getActivityId();
        if (CollectionUtils.isEmpty(dataList)) {
            return;
        }
        activeConversionRateMapper.updateLineData(dataList);
        activeConversionRateMapper.updateConversionRate();
    }
}

